﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using HandyControl.Expression.Shapes;
using 多协议通信平台.Entity;
using 多协议通信平台.Models;

namespace 多协议通信平台.UProfile
{
    public class ModbusPoint_Profile : Profile
    {
        public ModbusPoint_Profile()
        {
            // 简单映射（属性名相同）
            CreateMap<ModbusPoint, Data_ModbusPoint>();


            // 复杂映射（属性名不同）
            CreateMap<Data_ModbusPoint, ModbusPoint>()
                .ForMember(dest => dest.NodeID, opt => opt.MapFrom(src => src.NodeID))
                .ForMember(dest => dest.IP, opt => opt.MapFrom(src => src.IP))
                .ForMember(dest => dest.Port, opt => opt.MapFrom(src => src.Port))
                .ForMember(dest => dest.SlaveId, opt => opt.MapFrom(src => src.SlaveId))
                .ForMember(dest => dest.ComPort, opt => opt.MapFrom(src => src.ComPort))
                .ForMember(dest => dest.IsBaseOne, opt => opt.MapFrom(src => src.IsBaseOne))
                .ForMember(dest => dest.Address, opt => opt.MapFrom(src => src.Address))
                .ForMember(dest => dest.DataType, opt => opt.MapFrom(src => src.DataType))
                .ForMember(dest => dest.EndianType, opt => opt.MapFrom(src => src.EndianType));

                
        }
    }
}
